
package com.hyst.seviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hyst.domain.Recommend;
import com.hyst.domain.RecommendRecord;
import com.hyst.repository.RecommendRecordMapper;
import com.hyst.service.RecommendRecordService;
import com.hyst.utils.UuidTool;

/**
 * @Description:
 * @Date：2018年09月26日 
 * @author： dy 
 * @version ：1.0 1.[2018年09月26日]
 */
@Service
public class RecommendRecordServiceImpl implements RecommendRecordService {

	@Autowired
	private RecommendRecordMapper mapper;

	@Override
	public Page<RecommendRecord> list(final RecommendRecord recommendRecord) {
		final Page<RecommendRecord> page = PageHelper.startPage(recommendRecord.getPageNum(), recommendRecord.getPageSize());
		mapper.select(recommendRecord);
		return page;
	}

	@Override
	public RecommendRecord insert(final RecommendRecord recommendRecord) {
		recommendRecord.setUniqueId(UuidTool.randomUUID());
		mapper.insertSelective(recommendRecord);
		return recommendRecord;
	}

	@Override
	public RecommendRecord getByPriKey(final String uniqueId) {
		final RecommendRecord recommendRecord = mapper.selectByPrimaryKey(uniqueId);
		return recommendRecord;
	}

	@Override
	public RecommendRecord updateSelective(final RecommendRecord recommendRecord) {
		mapper.updateByPrimaryKeySelective(recommendRecord);
		return recommendRecord;
	}

	@Override
	public RecommendRecord update(final RecommendRecord recommendRecord) {
		mapper.updateByPrimaryKey(recommendRecord);
		return recommendRecord;
	}

	@Override
	public RecommendRecord delete(final String uniqueId) {

		return null;
	}

	// 2018-9-26 chenbin: 根据负责人Id查询
	public Page<RecommendRecord> getDataByFuzerenId(RecommendRecord recommendRecord, String fuzerenId) {
		final Page<RecommendRecord> page = PageHelper.startPage(recommendRecord.getPageNum(), recommendRecord.getPageSize());
		if(fuzerenId==""){
			fuzerenId=null;
		}
		RecommendRecord recmdRecord = new RecommendRecord();
		if (!fuzerenId.equals("all")){
			recmdRecord.setFuzerenId(fuzerenId);
		} else {
			recmdRecord.setFuzerenId("all");
		}
		mapper.getListFuzerenId(recmdRecord);
		return page;
	}
}
